//
//  CLPopWindowViewController.m
//  CareLink
//
//  Created by w on 16/8/21.
//  Copyright © 2016年 Seven Team. All rights reserved.
/**
 *  点击按钮出现弹窗效果
 *
 *  @param void <#void description#>
 *
 *  @return <#return value description#>
 */

#import "CLPopWindowViewController.h"

@interface CLPopWindowViewController (){
    //密码文本1
    UITextField *user;
    //密码文本
    UITextField *pwd;
    //边框背景
    UIView *bgView;
}
@end

@implementation CLPopWindowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor orangeColor];
    [self createTextFields];
    [self createLabel];
}
//点击按钮
- (void)clickAddBtn:(UIButton *)button{
    self.view.backgroundColor = [UIColor whiteColor];
    //exit函数中的实参是返回给操作系统,exit(0)正常退出 exit(1)非正常退出
    exit(0);
    
}
//固定的label页面
-(void)createLabel
{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 175, self.view.frame.size.width-15, 50)];
    label.text=@"▼温馨提示: 实名信息提交后不能随意修改,为确保您预约后能成功取号请不必填写真实信息";
    label.textColor = [UIColor grayColor];
    label.textAlignment=UITextAlignmentCenter;
    label.numberOfLines = 0;
    label.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:label];
}

//账号密码的文本布局
-(void)createTextFields
{
    CGRect frame = [UIScreen mainScreen].bounds;
    bgView = [[UIView alloc]initWithFrame:CGRectMake(10, 80, frame.size.width-20, 100)];
    //设置图层圆角
    bgView.layer.cornerRadius = 3.0;
    bgView.alpha = 0.7;
    bgView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bgView];
    //主界面账号
    user = [self createTextFielfFrame:CGRectMake(60, 10, 271, 30) font:[UIFont systemFontOfSize:14] placeholder:@"请输入真实姓名"];
    //user.text=@"118701646234";
    //密码样式带删除功能
    user.keyboardType=UIKeyboardTypeNumberPad;
    user.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    //主界面密码
    pwd = [self createTextFielfFrame:CGRectMake(60, 60, 271, 30) font:[UIFont systemFontOfSize:14]  placeholder:@"请输入证件号码" ];
    pwd.clearButtonMode = UITextFieldViewModeWhileEditing;
    //pwd.text=@"123456";
    //密码样式带删除功能
    pwd.secureTextEntry=YES;
    pwd.keyboardType=UIKeyboardTypeNumberPad;
    
    
    //设置登录账号密码背景图标
    UIImageView *userImageView = [self createImageViewFrame:CGRectMake(20, 10, 25, 25) imageName:@"ic_landing_nickname" color:nil];
    UIImageView *pwdImageView = [self createImageViewFrame:CGRectMake(20, 60, 25, 25) imageName:@"mm_normal" color:nil];
    //中间的分割线
    UIImageView *line1=[self createImageViewFrame:CGRectMake(20, 50, bgView.frame.size.width-40, 1) imageName:nil color:[UIColor colorWithRed:180/255.0f green:180/255.0f blue:180/255.0f alpha:.3]];
    
    UIButton *landBtn=[self createButtonFrame:CGRectMake(10, 220, self.view.frame.size.width-20, 37) backImageName:nil title:@"确定" titleColor:[UIColor whiteColor]  font:[UIFont systemFontOfSize:19] target:self action:@selector(landClickBtn)];
    //    [_landBtn setImage:[UIImage imageNamed:@"nav"] forState:UIControlStateNormal];
    landBtn.backgroundColor=[UIColor colorWithRed:8/255.0 green:65/255.0 blue:130/255.0 alpha:0.8];
    //landBtn.backgroundColor=[UIColor clearColor];
    landBtn.layer.cornerRadius=5.0f;
    
    //添加根视图
    [bgView addSubview:user];
    [bgView addSubview:pwd];
    
    
    [bgView addSubview:userImageView];
    [bgView addSubview:pwdImageView];
    [bgView addSubview:line1];
    [self.view addSubview:landBtn];
    
}

- (UITextField *)createTextFielfFrame:(CGRect)frame font:(UIFont *)font placeholder:(NSString *)placeholder
{
    UITextField *textField = [[UITextField alloc]initWithFrame:frame];
    
    
    textField.font=font;
    //grayColor 灰色
    textField.textColor = [UIColor grayColor];
    
    textField.borderStyle = UITextBorderStyleNone;
    
    textField.placeholder = placeholder;
    
    return textField;
}

- (UIImageView *)createImageViewFrame:(CGRect)frame imageName:(NSString *)imageName color:(UIColor *)color
{
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:frame];
    
    if (imageName)
    {
        imageView.image = [UIImage imageNamed:imageName];
    }
    if (color)
    {
        imageView.backgroundColor=color;
    }
    
    return imageView;
}

- (UIButton *)createButtonFrame:(CGRect)frame backImageName:(NSString *)imageName title:(NSString *)title titleColor:(UIColor *)color font:(UIFont *)font target:(id)target action:(SEL)action
{
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame=frame;
    if (imageName)
    {
        [btn setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    }
    
    if (font)
    {
        btn.titleLabel.font=font;
    }
    
    if (title)
    {
        [btn setTitle:title forState:UIControlStateNormal];
    }
    if (color)
    {
        [btn setTitleColor:color forState:UIControlStateNormal];
    }
    if (target&&action)
    {
        [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    }
    return btn;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
